!function() {
    var t = {
        isGradient: function(t) {
            return !(!t || !t.startsWith("linear") && !t.startsWith("radial"));
        },
        doGradient: function(s, l, t, a) {
            s.startsWith("linear") ? function(t, a, r) {
                for (var t = function(t, a, r) {
                    var n = t.match(/([-]?\d{1,3})deg/), t = n && n[1] ? parseFloat(n[1]) : 0, e = void 0;
                    switch (t) {
                      case 0:
                        e = [ 0, -r / 2, 0, r / 2 ];
                        break;

                      case 90:
                        e = [ a / 2, 0, -a / 2, 0 ];
                        break;

                      case -90:
                        e = [ -a / 2, 0, a / 2, 0 ];
                        break;

                      case 180:
                        e = [ 0, r / 2, 0, -r / 2 ];
                        break;

                      case -180:
                        e = [ 0, -r / 2, 0, r / 2 ];
                        break;

                      default:
                        var i = 0, s = 0, l = 0, o = 0;
                        s = (l = (o = (i = 0 < n[1] && n[1] < 90 ? a / 2 - (a / 2 * Math.tan((90 - n[1]) * Math.PI * 2 / 360) - r / 2) * Math.sin(2 * (90 - n[1]) * Math.PI * 2 / 360) / 2 : -180 < n[1] && n[1] < -90 ? -a / 2 + (a / 2 * Math.tan((90 - n[1]) * Math.PI * 2 / 360) - r / 2) * Math.sin(2 * (90 - n[1]) * Math.PI * 2 / 360) / 2 : 90 < n[1] && n[1] < 180 ? a / 2 + (-a / 2 * Math.tan((90 - n[1]) * Math.PI * 2 / 360) - r / 2) * Math.sin(2 * (90 - n[1]) * Math.PI * 2 / 360) / 2 : -a / 2 - (-a / 2 * Math.tan((90 - n[1]) * Math.PI * 2 / 360) - r / 2) * Math.sin(2 * (90 - n[1]) * Math.PI * 2 / 360) / 2, 
                        Math.tan((90 - n[1]) * Math.PI * 2 / 360) * i), -i), -o), e = [ i, s, l, o ];
                    }
                    return e;
                }(a, l, t), n = r.createLinearGradient(t[0], t[1], t[2], t[3]), e = o((a = a.match(/linear-gradient\((.+)\)/)[1]).substring(a.indexOf(",") + 1)), i = 0; i < e.colors.length; i++) n.addColorStop(e.percents[i], e.colors[i]);
                r.fillStyle = n;
            }(t, s, a) : s.startsWith("radial") && function(t, a, r) {
                for (var n = o(s.match(/radial-gradient\((.+)\)/)[1]), e = r.createCircularGradient(0, 0, t < a ? a / 2 : t / 2), i = 0; i < n.colors.length; i++) e.addColorStop(n.percents[i], n.colors[i]);
                r.fillStyle = e;
            }(l, t, a);
        }
    };
    function o(t) {
        var a = t.substring(0, t.length - 1).split("%,"), r = [], n = [], e = !0, i = !1, s = void 0;
        try {
            for (var l = a[Symbol.iterator](); !(e = (o = l.next()).done); e = !0) {
                var o = o.value;
                r.push(o.substring(0, o.lastIndexOf(" ")).trim()), n.push(o.substring(o.lastIndexOf(" "), o.length) / 100);
            }
        } catch (t) {
            i = !0, s = t;
        } finally {
            try {
                !e && l.return && l.return();
            } finally {
                if (i) throw s;
            }
        }
        return {
            colors: r,
            percents: n
        };
    }
    module.exports = {
        api: t
    };
}();